package com.ocean.web.controller.product;

import java.util.List;

import com.ocean.productDict.service.IOProductRepairTimeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ocean.common.annotation.Log;
import com.ocean.common.enums.BusinessType;
import com.ocean.productDict.domain.OProductRepairTime;
import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.utils.poi.ExcelUtil;
import com.ocean.common.core.page.TableDataInfo;

/**
 * 补传检查时间Controller
 *
 * @author ocean
 * @date 2023-01-11
 */
@Controller
@RequestMapping("/product/repairTime")
public class OProductRepairTimeController extends BaseController
{
    private String prefix = "product/time";

    @Autowired
    private IOProductRepairTimeService oProductRepairTimeService;

    @RequiresPermissions("product:time:view")
    @GetMapping()
    public String time()
    {
        return prefix + "/time";
    }

    /**
     * 查询补传检查时间列表
     */
    @RequiresPermissions("product:time:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OProductRepairTime oProductRepairTime)
    {
        startPage();
        List<OProductRepairTime> list = oProductRepairTimeService.selectOProductRepairTimeList(oProductRepairTime);
        return getDataTable(list);
    }

    /**
     * 导出补传检查时间列表
     */
    @RequiresPermissions("product:time:export")
    @Log(title = "补传检查时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OProductRepairTime oProductRepairTime)
    {
        List<OProductRepairTime> list = oProductRepairTimeService.selectOProductRepairTimeList(oProductRepairTime);
        ExcelUtil<OProductRepairTime> util = new ExcelUtil<OProductRepairTime>(OProductRepairTime.class);
        return util.exportExcel(list, "补传检查时间数据");
    }

    /**
     * 新增补传检查时间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存补传检查时间
     */
    @RequiresPermissions("product:time:add")
    @Log(title = "补传检查时间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OProductRepairTime oProductRepairTime)
    {
        return toAjax(oProductRepairTimeService.insertOProductRepairTime(oProductRepairTime));
    }

    /**
     * 修改补传检查时间
     */
    @RequiresPermissions("product:time:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        OProductRepairTime oProductRepairTime = oProductRepairTimeService.selectOProductRepairTimeById(id);
        mmap.put("oProductRepairTime", oProductRepairTime);
        return prefix + "/edit";
    }

    /**
     * 修改保存补传检查时间
     */
    @RequiresPermissions("product:time:edit")
    @Log(title = "补传检查时间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OProductRepairTime oProductRepairTime)
    {
        return toAjax(oProductRepairTimeService.updateOProductRepairTime(oProductRepairTime));
    }

    /**
     * 删除补传检查时间
     */
    @RequiresPermissions("product:time:remove")
    @Log(title = "补传检查时间", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(oProductRepairTimeService.deleteOProductRepairTimeByIds(ids));
    }
}
